package com.cedifie.lendapp.ui.steps.adapter

import android.graphics.Color
import android.widget.RelativeLayout
import androidx.recyclerview.widget.RecyclerView
import com.cedifie.lendapp.R
import com.cedifie.lib_baseadapter.CEDRecyclerViewAdapter
import com.cedifie.lib_baseadapter.CEDViewHolderHelper
import org.json.JSONObject

/**
 * Cedifie
 * @Author wwdeng
 * @CreateTime:  2024/6/18 14:46
 * @Annotation：流程 - 证件照类型
 */
class CedOcrTypeAdapter(recyclerView: RecyclerView?) : CEDRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_ocr_type) {

    override fun setItemChildListener(helper: CEDViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }

    override fun fillData(helper: CEDViewHolderHelper, position: Int, model: JSONObject) {
        val isSelect = model.optBoolean("isSelect", false)
        val itemLayout = helper.getView<RelativeLayout>(R.id.itemLayout)
        val imgIcon = helper.getImageView(R.id.imgIcon)
        imgIcon.setImageResource(model.optInt("iconId"))
        val textTitle = helper.getTextView(R.id.textTitle)
        textTitle.text = mContext.getString(model.optInt("title"))

        if (isSelect) {
            textTitle.setTextColor(Color.parseColor("#FF000000"))
            itemLayout.setBackgroundResource(R.drawable.ced_radius_fill_ffffffff_10)
        } else {
            textTitle.setTextColor(Color.parseColor("#FFA5A5A5"))
            itemLayout.setBackgroundResource(R.drawable.ced_radius_fill_fff4f3f3_10)
        }
    }
}